define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'resume_base/index' + location.search,
                    add_url: 'resume_base/add',
                    edit_url: 'resume_base/edit',
                    del_url: 'resume_base/del',
                    multi_url: 'resume_base/multi',
                    table: 'resume_base',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        {field: 'title', title: __('Title')},
                        {field: 'name', title: __('Name')},
                        {field: 'birth', title: __('Birth'), operate:'RANGE', addclass:'datetimerange'},
                        {field: 'age', title: __('Age')},
                        {field: 'email', title: __('Email')},
                        {field: 'sex', title: __('Sex'), searchList: {"0":__('Sex 0'),"1":__('Sex 1'),"2":__('Sex 2')}, formatter: Table.api.formatter.normal},
                        {field: 'mobile', title: __('Mobile')},
                        {field: 'job_class_id', title: __('Job_class_id')},
                        {field: 'work_year', title: __('Work_year')},
                        {field: 'edu_type', title: __('Edu_type')},
                        {field: 'citystr', title: __('Citystr')},
                        {field: 'provicecode', title: __('Provicecode')},
                        {field: 'provicecodestr', title: __('Provicecodestr')},
                        {field: 'citycode', title: __('Citycode')},
                        {field: 'citycodestr', title: __('Citycodestr')},
                        {field: 'areacode', title: __('Areacode')},
                        {field: 'areacodestr', title: __('Areacodestr')},
                        {field: 'place_citystr', title: __('Place_citystr')},
                        {field: 'place_provicecode', title: __('Place_provicecode')},
                        {field: 'place_provicecodestr', title: __('Place_provicecodestr')},
                        {field: 'place_citycode', title: __('Place_citycode')},
                        {field: 'place_citycodestr', title: __('Place_citycodestr')},
                        {field: 'place_areacode', title: __('Place_areacode')},
                        {field: 'place_areacodestr', title: __('Place_areacodestr')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});